package com.achao.usercenter.utils;

import com.achao.usercenter.exception.BusinessException;

public class ThrowUtils {

    /**
     * 抛出最大异常
     * @param runtimeException
     */
    public static void throwIf( RuntimeException runtimeException) {
        throw runtimeException;
    }

    /**
     * 条件成立则抛异常
     *
     * @param condition
     * @param runtimeException
     */
    public static void throwIf(boolean condition, RuntimeException runtimeException) {
        if (condition) {
            throw runtimeException;
        }
    }

    /**
     * 抛出异常
     * @param msg
     */
    public static void throwIf(String msg) {
        throwIf(new BusinessException(msg, 500, "系统异常"));
    }

    public static void throwIf(boolean condition, BusinessException businessException) {
        if (condition) {
            throw businessException;
        }
    }


}
